package org.softmed.rest.admin.aop;

import java.util.ArrayList;
import java.util.List;

import org.softmed.rest.config.Handler;
import org.softmed.rest.server.core.handler.HandlerProcessParameters;

public class Aspect {
	Long id;
	boolean active;
	String name;
	List<Rule> rules = new ArrayList<Rule>();
	Advice advice = new Advice();

	public boolean isApplicable(Handler handler,
			HandlerProcessParameters parameters) {
		if (!active)
			return false;

		for (Rule rule : rules) {
			if (rule.isApplicable(handler, parameters))
				return true;
		}
		return false;
	}

	private Object readResolve() {
		rules = new ArrayList<Rule>();
		return this;
	}

	public List<Rule> getRules() {
		return rules;
	}

	public void setRules(List<Rule> rules) {
		this.rules = rules;
	}

	public Advice getAdvice() {
		return advice;
	}

	public void setAdvice(Advice advice) {
		this.advice = advice;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	

}
